﻿<UserControl x:Class="Gallery.DragAndDrop.ItemsControlSample.ItemsControlSampleView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Gallery.DragAndDrop.ItemsControlSample"
             xmlns:apexMVVM="clr-namespace:Apex.MVVM;assembly=Apex.Silverlight"
             xmlns:apexControls="clr-namespace:Apex.Controls;assembly=Apex.Silverlight"
             xmlns:dragAndDrop="clr-namespace:Apex.DragAndDrop;assembly=Apex.Silverlight"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="600">
    
    <!-- The View creates its own ViewModel, so set the ViewModel 
    to a new instance of the ViewModel class. -->
    <UserControl.DataContext>
        <local:ItemsControlSampleViewModel x:Name="viewModel" />
    </UserControl.DataContext>

    <UserControl.Resources>
        <Style TargetType="ListBox">
            <Setter Property="Margin" Value="20" />
        </Style>
        <DataTemplate x:Key="draggableItemTemplate">
        <Border 
                dragAndDrop:DragAndDrop.IsDraggable="True" Margin="2" Padding="2">
            <TextBlock Text="{Binding}" />
        </Border>
    </DataTemplate>
    </UserControl.Resources>


        <dragAndDrop:DragAndDropHost x:Name="dragAndDropHost">
            <apexControls:ApexGrid Rows="*,*" Columns="*,*">

                <ItemsControl 
                Background="#22440044"
            x:Name="listTopLeft"
            Grid.Row="0" Grid.Column="0" ItemsSource="{Binding Group1}"
            ItemTemplate="{StaticResource draggableItemTemplate}"
            dragAndDrop:DragAndDrop.IsDragSource="True"
            dragAndDrop:DragAndDrop.IsDropTarget="True" />

                <ItemsControl
                Background="#22000044"
            x:Name="listTopRight"
            Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Group2}"
            ItemTemplate="{StaticResource draggableItemTemplate}"
            dragAndDrop:DragAndDrop.IsDragSource="True"
            dragAndDrop:DragAndDrop.IsDropTarget="True" />

                <ItemsControl 
                Background="#22004400"
            x:Name="listBottomLeft"
            Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Group3}"
            ItemTemplate="{StaticResource draggableItemTemplate}"
            dragAndDrop:DragAndDrop.IsDragSource="True"
            dragAndDrop:DragAndDrop.IsDropTarget="True" />

                <ItemsControl
                Background="#22440000"
            x:Name="listBottomRight"
            Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Group4}"
            ItemTemplate="{StaticResource draggableItemTemplate}"
            dragAndDrop:DragAndDrop.IsDragSource="True"
            dragAndDrop:DragAndDrop.IsDropTarget="True" />
            </apexControls:ApexGrid>
        </dragAndDrop:DragAndDropHost>
</UserControl>
